<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<title>title</title>
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
	<link rel="stylesheet" type="text/css" href="../css/icons.css" />
	<script src="../script/jquery-1.9.1.min.js"></script>
	<script src="../script/bootstrap.min.js"></script>
	<style>
		.table tr:first-child {
			background: url(static/img/tableheader-bg.gif) no-repeat left top;
			background-color: #DCE9F2;
			border-top: 1px solid #CBD6DE;
			border-bottom: 1px solid #ADBECB;
			color: #467aa7;
			font-size: 13px;
			font-weight: bold;
		}

		.table {
			margin-bottom: 15px;
			width: 100%;
			border-collapse: collapse;
			font-size: 13px;
			margin-bottom: 15px;
			width: 100%;
			border-collapse: collapse;
		}

		.table td {
			height: 40px;
			text-align: center;
			border: 1px solid #CBD6DE;
			padding: 0;
			margin: 0;
			vertical-align: middle !important;
		}

		/*#chkHCTable{
				font-size: 10px;
		}*/
	</style>
</head>

<body>
	<header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
		<a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
			<span class="aui-iconfont aui-icon-left"></span>
		</a>
		<div class="aui-title" id="title">
			设备点检
		</div>
	</header>
	<div class="aui-content" style="margin-top:50px;">

		<div class="aui-form">

			<div class="aui-content aui-margin-b-15">
				<ul class="aui-list aui-form-list" style="font-size: 14px;">
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="font-size: 14px;">设备编码</div>
							<input type="text" class="aui-input" placeholder="请 扫描/输入 设备编码"
								style="width: 80%;font-size: 14px;" id="sm">
							<!-- <i class="aui-input-addon aui-iconfont aui-icon-scan " style="font-size: 1.6rem"></i> -->
								<!-- onclick="toScanner();"></i> -->
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="font-size: 14px;">点检任务</div>
							<input type="text" class="aui-input" placeholder="选择点检任务"
								style="width: 80%;font-size: 14px;" id="chkTaskCode" value="">
								<!-- onclick="goSelectChkTask()"> -->
							<!-- <i class="aui-input-addon aui-iconfont aui-icon-right" style="font-size: 1.6rem"></i> -->
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="font-size: 14px;">执行状态</div>
							<div class="aui-list-item-input">
								<select id="zxState" style="font-size: 14px;">
									<option value="2" selected="true">进行</option>
									<option value="3">完成</option>
								</select>
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="font-size: 14px;">执行结果</div>
							<div class="aui-list-item-input">
								<select id="zxResult" style="font-size: 14px;">
									<option value="0">未判定</option>
									<option value="1">正常</option>
									<option value="2">异常</option>
								</select>
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="width:30%;font-size: 14px;">实际开始时间</div>
							<div class="aui-list-item-input" style="float:left;width: 70%;">
								<input type="text" id="actualBeginDate" onclick="showTime();">
							</div>
						</div>
					</li>
					<li class="aui-list-item" style="display: none;">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" style="width:20%;font-size: 14px;">实际结束时间</div>
							<div class="aui-list-item-input" style="float:left;width: 75%;">
								<input type="text" id="actualEndDate" onclick="showTime2();">
							</div>
						</div>
					</li>
				</ul>
			</div>
			<ul id="myTab" class="nav nav-tabs" style="background-color: #F4F4F4;font-size: 13px;">
				<li class="active" style="width: 33.33%;text-align:center;"> <a href="#item" data-toggle="tab">检修项 </a>

				</li>
				<li style="width: 33.33%;text-align:center;"> <a href="#hc" data-toggle="tab">检修耗材</a>

				</li>
				<li style="width: 33.33%;text-align:center;"> <a href="#yq" data-toggle="tab">检修仪器</a>

				</li>
			</ul>
			<div id="myTabContent" class="tab-content">
				<div class="tab-pane fade in active" id="item">
					<div style="background-color:white; height: 100%;width: 100%;">
						<table id="chkItemTable" class="table" style="width:200%;">
							<thead id="chkItemTableHead">
							</thead>
							<tbody id="chkItemTableBody">
							</tbody>
							<tbody id="chkItemTableBehind">
							</tbody>
						</table>
						<div class="aui-content">
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doAdd()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">添加检修项</span>

								</div>
								<p></p>
							</div>
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doDel()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">删除检修项</span>

								</div>
								<p></p>
							</div>
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doSave()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">提交数据</span>

								</div>
								<p></p>
							</div>
						</div>
					</div>
				</div>
				<div class="tab-pane fade" id="hc">
					<div style="background-color:white; height: 100%;width: 100%;">
						<table id="chkHCTable" class="table" style="width:100%;">
							<thead id="chkHCTableHead">
							</thead>
							<tbody id="chkHCTableBody">
							</tbody>

						</table>
						<div class="aui-content">
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doAddHC()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">添加耗材</span>
								</div>
								<p></p>
							</div>
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doDelHC()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">删除耗材</span>
								</div>
								<p></p>
							</div>
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doSave()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">提交数据</span>
								</div>
								<p></p>
							</div>
						</div>
					</div>
				</div>
				<div class="tab-pane fade" id="yq">
					<div style="background-color:white; height: 100%;width: 100%;">
						<table id="chkYqTable" class="table" style="width:100%;">
							<thead id="chkYqTableHead">
							</thead>
							<tbody id="chkYqTableBody">
							</tbody>

						</table>
						<div class="aui-content">
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doAddYq()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">添加仪器</span>

								</div>
								<p></p>
							</div>
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doDelYq()" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">删除仪器</span>

								</div>
								<p></p>
							</div>
							<div class="aui-content aui-content-padded" style="text-align:center;margin-bottom: 5%">
								<p>
								</p>
								<div class="aui-btn aui-btn-info" onclick="doSave(0)" style="width: 100%;height: 100%;">
									<span class="aui-iconfont" style="font-size: 20px;">提交数据</span>

								</div>
								<p></p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script>

	var taskId = "";
	var taskCode = "";
	var itemIds = "";
	var itemCodes = "";
	var itemNames = "";
	var itemModes = "";
	var itemValues = "";
	var itemMaxValues = "";
	var itemMinValues = "";
	var itemStandardValue = "";
	var josnList = [];
	var delItemIds = "";
	var str = "";
	var strHC = "";
	var strYQ = "";
	//检测维修耗材参数
	var HCId = "";
	var mrlGid = "";
	var mrlCode = "";
	var mrlName = "";
	var mrlExName = "";
	var qty = "";
	var measureName = "";
	var consumeType = "";
	var remark = "";
	var josnHCList = [];
	var delHCIds = "";

	//检测维修耗材仪器
	var YqId = "";
	var mrlYqGid = "";
	var mrlYqCode = "";
	var mrlYqName = "";
	var remarkYq = "";
	var josnYqList = [];
	var delYqIds = "";

	var YqIds = "";

	apiready = function () {
        var SRequipCode = api.pageParam.SRequipCode;
        var id = api.pageParam.id;
        var equipId = api.pageParam.equipId;
        var equipCode = api.pageParam.equipCode;
        var taskResult = api.pageParam.taskResult;
        var code = api.pageParam.code;
        $("#sm").val(SRequipCode);
        $("#chkTaskCode").val(code);
        setEquipTask(id,code,equipId,equipCode,taskResult);
	}
	//7；PDA自带扫描回车事件-设备编码
	$("#sm").on('keypress', function (e) { //#keyword为input文本框
		var keycode = e.keyCode;
		var sm = $(this).val();
		if (keycode == '13') {
			//设备编码
			$("#sm").val(sm);
		}
	});
	function showTime() {
		var moduleTimer = api.require('moduleTimer');
		moduleTimer.showTimer({
			startTime: '2000-01-1 00:00',//可选择的起始时间
			endTime: '2099-12-31 23:59',//可选择的结束时间
			timeFormat: 'yyyy-MM-dd HH:mm:ss',//返回的时间格式，如果不传默认是yyyy-MM-dd HH:mm:ss
			selColor: '#079962'//选中的颜色值
		}, function (ret, err) {
			var actualBeginDate = ret;
			var text = document.getElementById("actualBeginDate");
			text.value = actualBeginDate;
		});
	}

	function showTime2() {
		var moduleTimer = api.require('moduleTimer');
		moduleTimer.showTimer({
			startTime: '2000-01-1 00:00',//可选择的起始时间
			endTime: '2099-12-31 23:59',//可选择的结束时间
			timeFormat: 'yyyy-MM-dd HH:mm:ss',//返回的时间格式，如果不传默认是yyyy-MM-dd HH:mm:ss
			selColor: '#079962'//选中的颜色值
		}, function (ret, err) {
			var actualEndDate = ret;
			var text = document.getElementById("actualEndDate");
			text.value = actualEndDate;
		});
	}

	function toScanner() {
		var moduleScanner = api.require('moduleScanner');
		var params = {
			top: 150,//扫描窗口的上边距
			width: 250,//扫描窗口的宽
			height: 250,//扫描窗口的高
			useColor: false,//是否使用自己设定的颜色(startColor和endColor),
			//如果不使用设定的颜色就使用默认的那张网格图
			startColor: '#0F08C8FF',//渐变起始颜色
			endColor: '#7F08C8FF',//渐变结束颜色
			animTime: 2200,//扫描动画时间,单位为毫秒
		};
		moduleScanner.toScannerActivityForResult(params, function (ret, err) {
			//console.log(JSON.stringify(ret));
			var SMequipCode = ret;
			var text = document.getElementById("sm");
			text.value = SMequipCode;

		});

	}

	function goSelectChkTask() {
		var SRequipCode = document.getElementById("sm").value;
		if (SRequipCode == '') {
			//如果为空
			alert("请先扫设备编号");
			return;
		}
		var query = api.pageParam.query;
		var type = "";
		if(query.type!=undefined && query.type!=null && query.type!=""){
			type = query.type;
        }
		var url = "selEquipTaskList.html";
		var title = "点检任务列表";
		api.openWin({
			name: 'about8',
			url: 'about8.html',
			pageParam: {
				url: url,
				title: title,
				SRequipCode: SRequipCode,
				type :type
			}
		});
	}

	function setEquipTask(id, code, equipId, equipCode, taskResult) {
		taskId = id;
		equipId = equipId;
		$("#zxResult").children().remove();
		if (taskResult == 0) {
			var str = "<option value='0' selected='true'>未判定</option><option value='1' >正常</option><option value='2'>异常</option>";
			$("#zxResult").append(str);
		} else if (taskResult == 1) {
			var str = "<option value='0'>未判定</option><option value='1' selected='true'>正常</option><option value='2'>异常</option>";
			$("#zxResult").append(str);
		} else {
			var str = "<option value='0'>未判定</option><option value='1' >正常</option><option value='2' selected='true'>异常</option>";
			$("#zxResult").append(str);
		}
		$("#chkTaskCode").attr("value", code);
		//$("#actualBeginDate").attr("value", actualBeginDate);
		//$("#actualEndDate").attr("value", actualEndDate);
		if ("" != taskId) {
			//选择设备点检任务后，根据任务id获取点检项
			getEquipTaskItemByTask(taskId, equipId);
			//检测维修耗材
			//getEquipTaskHCByTask(taskId,equipId);
			//检测维修仪器
			//getEquipTaskYqByTask(taskId,equipId);
		}

	}

	//根据检测模板查找带回检测维修仪器
	function setEquipYqask(id, code, equipId, SRequipCode) {
		uckId = id;
		//uckCode = code;
		equipId = equipId;
		SRequipCode = SRequipCode;
		$("#chkTaskCode").attr("value", code);
		if ("" != uckId) {
			//选择设备点检任务后，根据任务id获取点检项
			getEquipTaskYqByTask(taskId, equipId);
		}
	}

	function setEquipHCTask(id, code, equipId, SRequipCode) {
		taskId = id;
		uckName = code;
		equipId = equipId;
		SRequipCode = SRequipCode;
		$("#chkTaskCode").attr("value", code);
		if ("" != taskId) {
			//选择设备点检任务后，根据任务id获取点检项
			getEquipTaskHCByTask(taskId, equipId);
		}
	}

	//根据检测模板查找带回检测维修仪器
	function getEquipTaskYqByTask(taskId, equipId) {
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/getChkYqByTask";
		var un = localStorage.getItem('un');

		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';

		var data = {
			values: {
				un: un,
				taskId: taskId,
				equipId: equipId
			}
		};

		// ajaxForData(params,data,false,function(ret, err){
		// 	var myobj=eval("("+ret.data+")");; 
		// 	$("#chkYqTable").children().remove();					
		// 	YqIds = "";
		// 	mrlYqGids = "";
		// 	mrlYqCodes = "";
		// 	mrlYqNames = "";					
		// 	remarkYqs = "";
		// 	$("#chkYqTable").append("<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td width='30%' algin='center'>物料编码</td><td width='30%' algin='center'>物料名称</td><td width='30%' algin='center'>备注</td></tr>");
		// 	for (var i = 0; i < myobj.length; i++) {
		// 		var YqId = myobj[i].YqId;
		// 		var mrlYqGid = myobj[i].mrlYqGid;
		// 		var mrlYqCode = myobj[i].mrlYqCode;
		// 		var mrlYqName = myobj[i].mrlYqName;					
		// 		var remarkYq = myobj[i].remarkYq;
		// 		var str = "";
		// 		if (i == 0) {
		// 			YqIds = YqId;
		// 			mrlYqGids = mrlYqGid;
		// 			mrlYqCodes = mrlYqCode;
		// 			mrlYqNames = mrlYqName;						
		// 			remarkYqs = remarkYq;
		// 		} else {
		// 			YqIds = YqIds + "," + YqId;
		// 			mrlYqGids = mrlYqGid + "," + mrlYqGid;
		// 			mrlYqCodes = mrlYqCodes + "," + mrlYqCode;
		// 			mrlYqNames = mrlYqNames + "," + mrlYqName;							
		// 			remarkYqs = remarkYqs + "," + remarkYq;
		// 		}
		// 		str = "<tr ><td width='10%' algin='center'>" + (i + 1) + "<input type='checkbox' onclick='setDelYq(\"" + YqId + "\");'></td><td style='display:none' algin='center'>" + mrlYqGid + "</td><td width='30%' algin='center'>" + mrlYqCode + "</td><td width='30%' algin='center'>" + mrlYqName + "</td><td width='30%' algin='center'><input id='remarkYq_" + YqId + "' type='text' value='" + remarkYq + "'></td></tr>"	

		// 		$("#chkYqTable").append(str);
		// 	}
		// });

		api.ajax({
			url: url,
			method: 'post',
			dataType: 'json',
			timeout: 300,
			returnAll: false,
			data: data
		}, function (ret, err) {
			if (ret) {
				var data = JSON.stringify(ret);
				var myobj = eval("(" + data + ")");
				//成功
				if (myobj.code == '0') {
					YqIds = "";
					mrlYqGids = "";
					mrlYqCodes = "";
					mrlYqNames = "";
					remarkYqs = "";
					var list = myobj.list;
					var html = "";
					var html9 = "";

					//	$api.html($api.byId("chkYqTable"), html1);
					// alert(html9)
					html9 += "<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td width='30%' algin='center'>物料编码</td><td width='30%' algin='center'>物料名称</td><td width='30%' algin='center'>备注</td></tr>";
					$api.html($api.byId("chkYqTableHead"), html9);

					for (var i = 0; i < list.length; i++) {
						var YqId = list[i].YqId;
						var mrlYqGid = list[i].mrlYqGid;
						var mrlYqCode = list[i].mrlYqCode;
						var mrlYqName = list[i].mrlYqName;
						var remarkYq = list[i].remarkYq;
						var str = "";
						if (i == 0) {
							YqIds = YqId;
							mrlYqGids = mrlYqGid;
							mrlYqCodes = mrlYqCode;
							mrlYqNames = mrlYqName;
							remarkYqs = remarkYq;
						} else {
							YqIds = YqIds + "," + YqId;
							mrlYqGids = mrlYqGid + "," + mrlYqGid;
							mrlYqCodes = mrlYqCodes + "," + mrlYqCode;
							mrlYqNames = mrlYqNames + "," + mrlYqName;
							remarkYqs = remarkYqs + "," + remarkYq;
						}
						if (i = 1) {
							strYQ = "<tr ><td width='10%' algin='center'>" + " " + "" + "<input type='checkbox' onclick='setDelYq(\"" + YqId + "\");'></td><td style='display:none' algin='center'>" + mrlYqGid + "</td><td width='30%' algin='center'>" + mrlYqCode + "</td><td width='30%' algin='center'>" + mrlYqName + "</td><td width='30%' algin='center'><input id='remarkYq_" + YqId + "' type='text' value='" + remarkYq + "'></td></tr>"

						} else {
							strYQ = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelYq(\"" + YqId + "\");'></td><td style='display:none' algin='center'>" + mrlYqGid + "</td><td width='30%' algin='center'>" + mrlYqCode + "</td><td width='30%' algin='center'>" + mrlYqName + "</td><td width='30%' algin='center'><input id='remarkYq_" + YqId + "' type='text' value='" + remarkYq + "'></td></tr>";
						}

						//$api.html($api.byId("chkYqTableBody"), strYQ);
						//$("#chkYqTableBody").append(strYQ);
						$("#chkYqTableHead").append(strYQ);
					}
					//chkYqTableHead
					//$("#chkYqTableHead").append(strYQ);
				} else if (myobj.code == '1') {
					api.toast({
						msg: myobj.message,
						duration: 3000
					});
				}
			}
		});
	}

	//根据检测模板查找带回检测维修耗材
	function getEquipTaskHCByTask(taskId, equipId) {
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/getChkHCByTask";
		var un = localStorage.getItem('un');

		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';
		params.returnAll = 'false';
		params.timeout = 60;

		var data = {
			values: {
				un: un,
				taskId: taskId,
				equipId: equipId
			}
		};

		// ajaxForData(params,data,false,function(ret, err){
		// 	var myobj=eval("("+ret.data+")");
		// 	$("#chkHCTable").children().remove();					
		// 	HCIds = "";
		// 	mrlGids = "";
		// 	mrlCodes = "";
		// 	mrlNames = "";
		// 	mrlExNames = "";
		// 	qtys = "";
		// 	measureNames = "";
		// 	consumeTypes = "";
		// 	remarks = "";
		// 	josnHCList = [];
		// 	$("#chkHCTable").append("<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td style='display:none' algin='center'>物料编号</td><td width='30%' algin='center'>物料名称</td><td width='20%' algin='center'>数量</td><td width='20%' algin='center'>消耗类型</td><td width='20%' algin='center'>备注</td></tr>");
		// 	for (var i = 0; i < myobj.length; i++) {
		// 		var HCId = myobj[i].HCId;
		// 		var mrlGid = myobj[i].mrlGid;
		// 		var mrlCode = myobj[i].mrlCode;
		// 		var mrlName = myobj[i].mrlName;
		// 		var mrlExName = myobj[i].mrlExName;
		// 		var qty = myobj[i].qty;
		// 		var measureName = myobj[i].measureName;
		// 		var consumeType = myobj[i].consumeType;
		// 		var remark = myobj[i].remark;
		// 		var str = "";
		// 		if (i == 0) {
		// 			HCIds = HCId;
		// 			mrlGids = mrlGid;
		// 			mrlCodes = mrlCode;
		// 			mrlNames = mrlName;
		// 			mrlExNames = mrlExName;
		// 			qtys = qty;
		// 			measureNames = measureName;
		// 			consumeTypes = consumeType;
		// 			remarks = remark;
		// 		} else {
		// 			HCIds = HCIds + "," + HCId;
		// 			mrlGids = mrlGid + "," + mrlGid;
		// 			mrlCodes = mrlCodes + "," + mrlCode;
		// 			mrlNames = mrlNames + "," + mrlName;
		// 			mrlExNames = mrlExNames + "," + mrlExName;
		// 			qtys = qtys + "," + qty;
		// 			measureNames = measureNames + "," + measureName;
		// 			consumeTypes = consumeTypes + "," + consumeType;
		// 			remarks = remarks + "," + remark;
		// 		}
		// 		if (consumeType == "0") {
		// 			str = "<tr ><td width='10%' algin='center'>" + (i + 1) + "<input type='checkbox' onclick='setDelHC(\"" + HCId + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + mrlCode + "</td><td width='30%' algin='center'>" + mrlName + "</td><td width='20%' algin='center'><input id='qty_" + HCId + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCId + "'><option value='0' selected='true'>替换</option><option value='1'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCId + "' type='text' value='" + remark + "'></td></tr>"	
		// 		}else if(consumeType == "1"){
		// 			str = "<tr ><td width='10%' algin='center'>" + (i + 1) + "<input type='checkbox' onclick='setDelHC(\"" + HCId + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + mrlCode + "</td><td width='30%' algin='center'>" + mrlName + "</td><td width='20%' algin='center'><input id='qty_" + HCId + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCId + "'><option value='0'>替换</option><option value='1' selected='true'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCId + "' type='text' value='" + remark + "'></td></tr>"	
		// 		}else{
		// 			str = "<tr ><td width='10%' algin='center'>" + (i + 1) + "<input type='checkbox' onclick='setDelHC(\"" + HCId + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + mrlCode + "</td><td width='30%' algin='center'>" + mrlName + "</td><td width='20%' algin='center'><input id='qty_" + HCId + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCId + "'><option value='1'>替换</option><option value='1'>废弃</option><option value='2' selected='true'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCId + "' type='text' value='" + remark + "'></td></tr>"	
		// 		}

		// 		$("#chkHCTable").append(str);
		// 		//检测维修仪器
		// 		getEquipTaskYqByTask(taskId,equipId);
		// 	}
		// });

		api.ajax({
			url: url,
			method: 'post',
			dataType: 'json',
			timeout: 300,
			returnAll: false,
			data: data
		}, function (ret, err) {
			if (ret) {
				var data = JSON.stringify(ret);
				var myobj = eval("(" + data + ")");
				//成功
				if (myobj.code == '0') {
					HCIds = "";
					mrlGids = "";
					mrlCodes = "";
					mrlNames = "";
					mrlExNames = "";
					qtys = "";
					measureNames = "";
					consumeTypes = "";
					remarks = "";

					josnHCList = [];
					var list = myobj.list;
					var html1 = ""; //chkHCTable
					html1 += "<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td style='display:none' algin='center'>物料编号</td><td width='30%' algin='center'>物料名称</td><td width='20%' algin='center'>数量</td><td width='20%' algin='center'>消耗类型</td><td width='20%' algin='center'>备注</td></tr>";
					$api.html($api.byId("chkHCTableHead"), html1);
					for (var i = 0; i < list.length; i++) {
						var HCId = list[i].HCId;
						var mrlGid = list[i].mrlGid;
						var mrlCode = list[i].mrlCode;
						var mrlName = list[i].mrlName;
						var mrlExName = list[i].mrlExName;
						var qty = list[i].qty;
						var measureName = list[i].measureName;
						var consumeType = list[i].consumeType;
						var remark = list[i].remark;
						var str = "";
						if (i == 0) {
							HCIds = HCId;
							mrlGids = mrlGid;
							mrlCodes = mrlCode;
							mrlNames = mrlName;
							mrlExNames = mrlExName;
							qtys = qty;
							measureNames = measureName;
							consumeTypes = consumeType;
							remarks = remark;
						} else {
							HCIds = HCIds + "," + HCId;
							mrlGids = mrlGid + "," + mrlGid;
							mrlCodes = mrlCodes + "," + mrlCode;
							mrlNames = mrlNames + "," + mrlName;
							mrlExNames = mrlExNames + "," + mrlExName;
							qtys = qtys + "," + qty;
							measureNames = measureNames + "," + measureName;
							consumeTypes = consumeTypes + "," + consumeType;
							remarks = remarks + "," + remark;
						}
						if (consumeType == "0") {
							strHC = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + HCId + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + mrlCode + "</td><td width='30%' algin='center'>" + mrlName + "</td><td width='20%' algin='center'><input id='qty_" + HCId + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCId + "'><option value='0' selected='true'>替换</option><option value='1'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCId + "' type='text' value='" + remark + "'></td></tr>"
						} else if (consumeType == "1") {
							strHC = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + HCId + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + mrlCode + "</td><td width='30%' algin='center'>" + mrlName + "</td><td width='20%' algin='center'><input id='qty_" + HCId + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCId + "'><option value='0'>替换</option><option value='1' selected='true'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCId + "' type='text' value='" + remark + "'></td></tr>"
						} else {
							strHC = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + HCId + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + mrlCode + "</td><td width='30%' algin='center'>" + mrlName + "</td><td width='20%' algin='center'><input id='qty_" + HCId + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCId + "'><option value='1'>替换</option><option value='1'>废弃</option><option value='2' selected='true'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCId + "' type='text' value='" + remark + "'></td></tr>"
						}

						//$("#chkHCTable").append(str);
						//$api.html($api.byId("chkHCTableBody"), strHC);
						//检测维修仪器
						$("#chkHCTableHead").append(strHC);
					}
					//$("#chkHCTableHead").append(strHC);
					//检测维修仪器
					getEquipTaskYqByTask(taskId, equipId);
				} else if (myobj.code == '1') {
					api.toast({
						msg: myobj.message,
						duration: 3000
					});
				}
			}
		});
	}

	function getEquipTaskItemByTask(taskId, equipId) {
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/getChkItemByTask";
		var un = localStorage.getItem('un');

		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';
		params.returnAll = 'false';
		params.timeout = 60;

		var data = {
			values: {
				un: un,
				taskId: taskId,
				equipId: equipId
			}
		};

		// ajaxForData(params,data,false,function(ret, err){
		// 	var myobj=eval("("+ret.data+")");
		// 	$("#chkItemTable").children().remove();

		// 	itemIds = "";
		// 	itemCodes = "";
		// 	itemNames = "";
		// 	itemModes = "";
		// 	itemValues = "";
		// 	itemMaxValues = "";
		// 	itemMinValues = "";
		// 	itemStandardValue = "";

		// 	josnList=[];

		// 	$("#chkItemTable").append("<tr id='tr1'><td width='10%' algin='center'>序号</td><td algin='center' style='display:none;'>编号</td><td width='50%' algin='center'>点检项</td><td width='15%' algin='center'>标准值</td><td width='25%' algin='center'>检测值</td></tr>");
		//     for (var i = 0; i < myobj.length; i++) {

		// 		var itemId = myobj[i].itemId;
		// 		var itemCode = myobj[i].itemCode;
		// 		var itemName = myobj[i].itemName;
		// 		var chkMode = myobj[i].chkMode;
		// 		var maxValue = myobj[i].maxValue;
		// 		var chkValue = myobj[i].chkValue;
		// 		var minValue = myobj[i].minValue;
		// 		var standardValue = myobj[i].standardValue;
		// 		var chkResult = myobj[i].chkResult;
		// 		var str ="";

		// 		if(i == 0)
		// 		{
		// 			itemIds = itemId+":"+chkMode;
		// 			itemCodes = itemCode;
		// 			itemNames = itemName;
		// 			itemMaxValues = maxValue;
		// 			itemMinValues = minValue;
		// 			itemStandardValue = standardValue;

		// 		}else{
		// 			itemIds = itemIds + "," +itemId+":"+chkMode;
		// 			itemCodes = itemCodes + "," + itemCode;
		// 			itemNames = itemNames + "," + itemName;
		// 			itemMaxValues = itemMaxValues + "," + maxValue;
		// 			itemMinValues = itemMinValues + "," + minValue;
		// 			itemStandardValue = itemStandardValue + "," + standardValue;
		// 		}

		// 		if(chkMode == "0")
		// 		{
		// 			if(chkResult == "1")
		// 			{
		// 				str = "<tr ><td width='10%' algin='center'>"+(i+1)+"<input type='checkbox' onclick='setDelItem(\""+itemId+"\");'></td><td algin='center' style='display:none;'>"+itemCode+"</td><td width='50%' algin='center'>"+itemName+"</td><td width='15%' algin='center'>"+standardValue+"</td><td width='25%' algin='left'><select id='"+itemId+"'><option value='0'>未判定</option><option value='1' selected='true'>正常</option><option value='2'>异常</option></select></td></tr>"
		// 			}else if(chkResult == "2"){
		// 				str = "<tr ><td width='10%' algin='center'>"+(i+1)+"<input type='checkbox' onclick='setDelItem(\""+itemId+"\");'></td><td algin='center' style='display:none;'>"+itemCode+"</td><td width='50%' algin='center'>"+itemName+"</td><td width='15%' algin='center'>"+standardValue+"</td><td width='25%' algin='left'><select id='"+itemId+"'><option value='0'>未判定</option><option value='1'>正常</option><option value='2' selected='true'>异常</option></select></td></tr>"
		// 			}else{
		// 				str = "<tr ><td width='10%' algin='center'>"+(i+1)+"<input type='checkbox' onclick='setDelItem(\""+itemId+"\");'></td><td algin='center' style='display:none;'>"+itemCode+"</td><td width='50%' algin='center'>"+itemName+"</td><td width='15%' algin='center'>"+standardValue+"</td><td width='25%' algin='left'><select id='"+itemId+"'><option value='0' selected='true'>未判定</option><option value='1'>正常</option><option value='2'>异常</option></select></td></tr>"
		// 			}

		// 		}
		// 		if(chkMode == "1")
		// 		{
		// 			str = "<tr ><td width='10%' algin='center'>"+(i+1)+"<input type='checkbox' onclick='setDelItem(\""+itemId+"\");'></td><td algin='center' style='display:none;'>"+itemCode+"</td><td width='50%' algin='center'>"+itemName+"</td><td width='15%' algin='center'>"+standardValue+"</td><td width='25%' algin='center'><input id='"+itemId+"' type='text' value='"+chkValue+"'></td></tr>"
		// 		}
		// 		$("#chkItemTable").append(str);
		// 		console.log(itemMaxValues);
		// 		console.log(itemMinValues);
		// 		//检测维修耗材
		// 		getEquipTaskHCByTask(taskId,equipId);
		// 	}	
		// });

		api.ajax({
			url: url,
			method: 'post',
			dataType: 'json',
			timeout: 300,
			returnAll: false,
			data: data
		}, function (ret, err) {
			if (ret) {
				var data = JSON.stringify(ret);
				var myobj = eval("(" + data + ")");
				//成功
				if (myobj.code == '0') {
					itemIds = "";
					itemCodes = "";
					itemNames = "";
					itemModes = "";
					itemValues = "";
					itemMaxValues = "";
					itemMinValues = "";
					itemStandardValue = "";

					josnList = [];
					var list = myobj.list;
					var html = "";
					var html1 = "";
					html1 += "<tr id='tr1' color: #467aa7;>";
					html1 += "<td width='10%' algin='center'>序号</td>";
					html1 += "<td algin='center' style='display:none;'>编号</td>";
					html1 += "<td width='25%' algin='center'>点检项</td>";
					html1 += "<td width='15%' algin='center'>最大值</td>";
					html1 += "<td width='15%' algin='center'>标准值</td>";
					html1 += "<td width='15%' algin='center'>最小值</td>";
					html1 += "<td width='25%' algin='center'>检测值</td></tr>";

					$api.html($api.byId("chkItemTableHead"), html1);
					str = "";
					console.log(JSON.stringify(list))
					if (list != undefined) {
						//遍历
						for (var i = 0; i < list.length; i++) {
							var itemId = list[i].itemId;
							var itemCode = list[i].itemCode;
							var itemName = list[i].itemName;
							var chkMode = list[i].chkMode;
							var maxValue = list[i].maxValue;
							var chkValue = list[i].chkValue;
							var minValue = list[i].minValue;
							var standardValue = list[i].standardValue;
							var chkResult = list[i].chkResult;

							if (i == 0) {
								itemIds = itemId + ":" + chkMode;
								itemCodes = itemCode;
								itemNames = itemName;
								itemMaxValues = maxValue;
								itemMinValues = minValue;
								itemStandardValue = standardValue;

							} else {
								itemIds = itemIds + "," + itemId + ":" + chkMode;
								itemCodes = itemCodes + "," + itemCode;
								itemNames = itemNames + "," + itemName;
								itemMaxValues = itemMaxValues + "," + maxValue;
								itemMinValues = itemMinValues + "," + minValue;
								itemStandardValue = itemStandardValue + "," + standardValue;
							}

							if (chkMode == "0") {
								if (chkResult == "1") {
									str += "<tr ><td width='10%' algin='center'>" +
										"" + "<input type='checkbox' onclick='setDelItem(\"" + itemId + "\");'></td><td algin='center' style='display:none;'>"
										+ itemCode + "</td><td width='25%' algin='center'>"
										+ itemName + "</td><td width='15%' algin='center'>"
										+ maxValue + "</td><td width='15%' algin='center'>"
										+ standardValue + "</td><td width='15%' algin='center'>"
										+ minValue + "</td><td width='25%' algin='left'><select id='"
										+ itemId + "'><option value='0'>未判定</option><option value='1' selected='true'>正常</option><option value='2'>异常</option></select></td></tr>"
								} else if (chkResult == "2") {
									str += "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\"" + itemId + "\");'></td><td algin='center' style='display:none;'>"
										+ itemCode + "</td><td width='25%' algin='center'>"
										+ itemName + "</td><td width='15%' algin='center'>"
										+ maxValue + "</td><td width='15%' algin='center'>"
										+ standardValue + "</td><td width='15%' algin='center'>"
										+ minValue + "</td><td width='25%' algin='left'><select id='"
										+ itemId + "'><option value='0'>未判定</option><option value='1'>正常</option><option value='2' selected='true'>异常</option></select></td></tr>"
								} else {
									str += "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
										+ itemId + "\");'></td><td algin='center' style='display:none;'>"
										+ itemCode + "</td><td width='25%' algin='center'>"
										+ itemName + "</td><td width='15%' algin='center'>"
										+ maxValue + "</td><td width='15%' algin='center'>"
										+ standardValue + "</td><td width='15%' algin='center'>"
										+ minValue + "</td><td width='25%' algin='left'><select id='"
										+ itemId + "'><option value='0' selected='true'>未判定</option><option value='1'>正常</option><option value='2'>异常</option></select></td></tr>"
								}

							}
							if (chkMode == "1") {
								str += "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\"" + itemId + "\");'></td><td algin='center' style='display:none;'>" + itemCode + "</td><td width='50%' algin='center'>" + itemName + "</td><td width='15%' algin='center'>" + standardValue + "</td><td width='25%' algin='center'><input id='" + itemId + "' type='text' value='" + chkValue + "'></td></tr>"
							}
							//$("#chkItemTable").append(str);
							console.log(itemMaxValues);
							console.log(itemMinValues);
						}
					}
					$("#chkItemTableHead").append(str);
					//$api.html($api.byId("chkItemTableBody"), str);
					//检测维修耗材
					getEquipTaskHCByTask(taskId, equipId);
				} else if (myobj.code == '1') {
					api.toast({
						msg: myobj.message,
						duration: 3000
					});
				}
			}
		});
	}

	function setAddItem(itemStrs) {
		if (itemStrs == "") {
			//未添加点检项
		} else {
			//将选择添加的点检项添加到表格中
			var itemStrArr = itemStrs.split(",");
			// alert(itemStrArr);
			var trStr = "";
			var nums = itemIds.split(",").length;
			var nums2 = itemIds.split(",");
			for (i = 0; i < itemStrArr.length; i++) {
				var itemArr = itemStrArr[i].split(":");
				console.log(itemArr);
				var id = itemArr[0];
				var code = itemArr[1];
				var name = itemArr[2];
				var mode = itemArr[3];
				var maxValue = itemArr[4];
				var minValue = itemArr[5];
				var standardValue = itemArr[6];

				if (itemIds == "") {
					itemIds = id + ":" + mode;
					itemCodes = code;
					itemNames = name;
				} else {
					itemIds = itemIds + "," + id + ":" + mode;
					itemCodes = itemCodes + "," + code;
					itemNames = itemNames + "," + name;
				}
				// alert("nums : " + nums)
				// alert("nums2 : " + nums2)
				// alert("mode : " + mode)
				if (nums == 1) {
					if (nums2 == "") {
						if (mode == "0") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
								+ id + "\");'></td><td algin='center' style='display:none;'>"
								+ code + "</td><td width='25%' algin='center'>"
								+ name + "</td><td width='15%' algin='center'>"
								+ maxValue + "</td><td width='15%' algin='center'>"
								+ standardValue + "</td><td width='15%' algin='center'>"
								+ minValue + "</td><td width='30%' algin='left'><select id='"
								+ id + "'><option value='0' selected='true'>未判定</option><option value='1'>正常</option><option value='2'>异常</option></select></td></tr>"
						}
						if (mode == "1") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
								+ id + "\");'></td><td algin='center' style='display:none;'>"
								+ code + "</td><td width='25%' algin='center'>"
								+ name + "</td><td width='15%' algin='center'>"
								+ maxValue + "</td><td width='15%' algin='center'>"
								+ standardValue + "</td><td width='15%' algin='center'>"
								+ minValue + "</td><td width='30%' algin='center'><input id='"
								+ id + "' type='text' value=''></td></tr>"
						}
					} else {
						if (mode == "0") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
								+ id + "\");'></td><<td algin='center' style='display:none;'>"
								+ code + "</td><td width='25%' algin='center'>"
								+ name + "</td><td width='15%' algin='center'>"
								+ maxValue + "</td><td width='15%' algin='center'>"
								+ standardValue + "</td><td width='15%' algin='center'>"
								+ minValue + "</td><td width='30%' algin='left'><select id='"
								+ id + "'><option value='0' selected='true'>未判定</option><option value='1'>正常</option><option value='2'>异常</option></select></td></tr>"
						}
						if (mode == "1") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
								+ id + "\");'></td><td algin='center' style='display:none;'>"
								+ code + "</td><td width='25%' algin='center'>"
								+ name + "</td><td width='15%' algin='center'>"
								+ maxValue + "</td><td width='15%' algin='center'>"
								+ standardValue + "</td><td width='15%' algin='center'>"
								+ minValue + "</td><td width='30%' algin='center'><input id='"
								+ id + "' type='text' value=''></td></tr>"
						}
					}
				} else {
					if (mode == "0") {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
							+ id + "\");'></td><td algin='center' style='display:none;'>"
							+ code + "</td><<td width='25%' algin='center'>"
							+ name + "</td><td width='15%' algin='center'>"
							+ maxValue + "</td><td width='15%' algin='center'>"
							+ standardValue + "</td><td width='15%' algin='center'>"
							+ minValue + "</td><td width='30%' algin='left'><select id='"
							+ id + "'><option value='0' selected='true'>未判定</option><option value='1'>正常</option><option value='2'>异常</option></select></td></tr>"
					}
					if (mode == "1") {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelItem(\""
							+ id + "\");'></td><td algin='center' style='display:none;'>"
							+ code + "</td><td width='25%' algin='center'>"
							+ name + "</td><td width='15%' algin='center'>"
							+ maxValue + "</td><td width='15%' algin='center'>"
							+ standardValue + "</td><td width='15%' algin='center'>"
							+ minValue + "</td><td width='30%' algin='center'><input id='"
							+ id + "' type='text' value=''></td></tr>"
					}
				}

				$("#chkItemTableHead").append(trStr);
			}
			if (trStr != "") {

				//	$("#chkItemTableBody").append(trStr);
			}
		}
	}

	function doAdd() {
		var taskCode = $("#chkTaskCode").val();
		//	alert(itemCodes);
		if (taskCode != "") {
			//根据现有的点检项，获取新的点检项		
			var url = "selEquipItemList.html";
			var title = "设备检测项列表";
			api.openWin({
				name: 'equipItem',
				url: url,
				pageParam: {
					title: title,
					itemCodes: itemCodes
				}
			});
		} else {
			alert("请选择点检任务");
		}
	}

	//检测维修耗材(点击添加检测维修耗材按钮带回来)
	function setAddHC(HCStrs) {
		if (HCStrs == "") {
			//未添加点检项
		} else {
			//将选择添加的点检项添加到表格中
			var HCStrs = HCStrs.split(",");
			var trStr = "";
			var nums = HCIds.split(",").length;
			var nums2 = HCIds.split(",");
			for (i = 0; i < HCStrs.length; i++) {
				var HCArr = HCStrs[i].split(":");
				var id = HCArr[0];
				var mrlGid = HCArr[1];
				var code = HCArr[2];
				var name = HCArr[3];
				var consumeType = HCArr[4];
				var qty = HCArr[5];
				var remark = HCArr[6];
				if (HCIds == "") {
					HCIds = id;
					mrlGids = mrlGid;
					mrlCodes = code;
					mrlNames = name;
					consumeTypes = consumeTypes + "," + consumeType;
					qtys = qty;
					remarks = remark;
				} else {
					HCIds = HCIds + "," + id;
					mrlGids = mrlGids + "," + mrlGid;
					mrlCodes = mrlCodes + "," + code;
					mrlNames = mrlNames + "," + name;
					consumeTypes = consumeTypes + "," + consumeType;
					qtys = qtys + "," + qty;
					remarks = remarks + "," + remark;
				}
				if (nums == 1) {
					if (nums2 == "") {
						if (consumeType == "0") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0' selected='true'>替换</option><option value='1'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
						}
						if (consumeType == "1") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0'>替换</option><option value='1' selected='true'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
						}
						else {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0'>替换</option><option value='1'>废弃</option><option value='2' selected='true'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
						}
					} else {
						if (consumeType == "0") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0' selected='true'>替换</option><option value='1'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
						}
						if (consumeType == "1") {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0'>替换</option><option value='1' selected='true'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
						}
						else {
							trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0'>替换</option><option value='1'>废弃</option><option value='2' selected='true'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
						}
					}
				} else {
					if (consumeType == "0") {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0' selected='true'>替换</option><option value='1'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
					}
					if (consumeType == "1") {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0'>替换</option><option value='1' selected='true'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
					}
					else {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelHC(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td style='display:none' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='20%' algin='center'><input id='qty_" + id + "' type='text' value='" + qty + "'></td><td width='20%' algin='left'><select id='consumeType_" + id + "'><option value='0'>替换</option><option value='1'>废弃</option><option value='2' selected='true'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + id + "' type='text' value='" + remark + "'></td></tr>"
					}

				}
				//$("#chkHCTable").append(trStr);
				if (trStr != "") {
					//	alert("str :" + str)
					//	alert("trStr :" + trStr)
					//	str += trStr;
					//	$api.html($api.byId("chkHCTableBody"), trStr);
					$("#chkHCTableHead").append(trStr);
				}
			}
		}
	}

	//添加检测维修耗材
	function doAddHC() {
		var taskCode = $("#chkTaskCode").val();
		if (taskCode != "") {
			//根据现有的点检项，获取新的点检项		
			var url = "selEquipCHKHCList.html";
			var title = "检测维修耗材";
			api.openWin({
				name: 'equipHC',
				url: url,
				pageParam: {
					title: title,
					mrlCodes: mrlCodes
				}
			});
		} else {
			alert("请选择点检任务");
		}
	}

	function setDelItem(id) {
		if (delItemIds == "") {
			delItemIds = id;
		} else {
			if (delItemIds.indexOf(id) > 0) {
				//已存在
				var delArr = delItemIds.split(",");
				delItemIds = "";
				for (i = 0; i < delArr.length; i++) {
					if (delArr[i] != id) {
						if (i == 0) {
							delItemIds = delArr[i];
						} else {
							delItemIds = delItemIds + "," + delArr[i];
						}
					}

				}
			} else {
				//不存在
				delItemIds = delItemIds + "," + id;
			}
		}
	}

	//删除检测维修耗材
	function setDelHC(id) {
		if (delHCIds == "") {
			delHCIds = id;
		} else {
			if (delHCIds.indexOf(id) > 0) {
				//已存在
				var delArr = delHCIds.split(",");
				delHCIds = "";
				for (i = 0; i < delArr.length; i++) {
					if (delArr[i] != id) {
						if (i == 0) {
							delHCIds = delArr[i];
						} else {
							delHCIds = delHCIds + "," + delArr[i];
						}
					}
				}
			} else {
				//不存在
				delHCIds = delHCIds + "," + id;
			}
		}
	}

	//检测维修仪器(点击添加检测维修仪器按钮带回来)
	function setAddYq(YqStrs) {
		if (YqStrs == "") {
			//未添加点检项
		} else {
			//将选择添加的点检项添加到表格中
			var YqStrs = YqStrs.split(",");
			var trStr = "";
			var nums = YqIds.split(",").length;
			var nums2 = YqIds.split(",");
			for (i = 0; i < YqStrs.length; i++) {
				var YqArr = YqStrs[i].split(":");
				var id = YqArr[0];
				var mrlGid = YqArr[1];
				var code = YqArr[2];
				var name = YqArr[3];
				var remark = YqArr[4];

				if (YqIds == "") {
					YqIds = id;
					mrlYqGids = mrlGid;
					mrlYqCodes = code;
					mrlYqNames = name;
					remarkYqs = remark;
				} else {
					YqIds = YqIds + "," + id;
					mrlYqGids = mrlYqGids + "," + mrlGid;
					mrlYqCodes = mrlYqCodes + "," + code;
					mrlYqNames = mrlYqNames + "," + name;
					remarkYqs = remarkYqs + "," + remark;
				}
				if (nums == 1) {
					if (nums2 == "") {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelYq(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td width='30%' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='30%' algin='center'><input id='remarkYq_" + id + "' type='text' value='" + remark + "'></td></tr>"
					} else {
						trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelYq(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td width='30%' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='30%' algin='center'><input id='remarkYq_" + id + "' type='text' value='" + remark + "'></td></tr>"
					}
				} else {
					trStr = "<tr ><td width='10%' algin='center'>" + "" + "<input type='checkbox' onclick='setDelYq(\"" + id + "\");'></td><td style='display:none' algin='center'>" + mrlGid + "</td><td width='30%' algin='center'>" + code + "</td><td width='30%' algin='center'>" + name + "</td><td width='30%' algin='center'><input id='remarkYq_" + id + "' type='text' value='" + remark + "'></td></tr>"
				}
				if (trStr != "") {
					$("#chkYqTableHead").append(trStr);
				}
			}
		}
	}

	//添加检测维修仪器
	function doAddYq() {
		var taskCode = $("#chkTaskCode").val();
		if (taskCode != "") {
			//根据现有的点检项，获取新的点检项
			var url = "selEquipCHKModelYqList.html";
			var title = "检测维修耗材";
			api.openWin({
				name: 'equipYq',
				url: url,
				pageParam: {
					title: title,
					mrlYqCodes: mrlYqCodes
				}
			});
		} else {
			alert("请选择点检任务");
		}
	}

	function doDel() {
		if (delItemIds != "") {
			//过滤掉要删除的点检项
			setItemValues();


			var idArr = itemIds.split(",");
			var codeArr = itemCodes.split(",");
			var nameArr = itemNames.split(",");
			var maxValueArr = itemMaxValues.split(",");
			var minValueArr = itemMinValues.split(",");
			var standardValueArr = itemStandardValue.split(",");
			var valueArr = itemValues.split(",");

			itemIds = "";
			itemCodes = "";
			itemNames = "";
			maxValues = "";
			minValues = "";
			standardValues = "";
			josnList = [];

			var itemIdStr = "";

			//$("#chkItemTableHead").children().remove();
			$("#chkItemTableHead").children().remove();
			$("#chkItemTableHead").append("<tr id='tr1'><td width='10%' algin='center'>序号</td><td width='10%' algin='center'>编号</td><td width='25%' algin='center'>点检项</td><td width='15%' algin='center'>最大值</td><td width='15%' algin='center'>标准值</td><td width='15%' algin='center'>最小值</td><td width='30%' algin='center'>检测值</td></tr>");
			//var html = "<tr id='tr1'><td width='10%' algin='center'>序号</td><td width='10%' algin='center'>编号</td><td width='50%' algin='center'>点检项</td><td width='30%' algin='center'></td></tr>";
			//$api.html($api.byId("chkItemTableHead"), html);
			var seq = 0;
			for (i = 0; i < idArr.length; i++) {
				itemIdStr = idArr[i].split(":")[0];
				if (delItemIds.indexOf(itemIdStr) < 0) {
					seq++;
					//不在要删除的id字符串中
					var strDel = "";
					if (i == 0) {
						itemIds = idArr[i];
						itemCodes = codeArr[i];
						itemNames = nameArr[i];
						maxValues = maxValueArr[i];
						minValues = minValueArr[i];
						standardValues = standardValueArr[i];
					} else {
						itemIds = itemIds + "," + idArr[i];
						itemCodes = itemCodes + "," + codeArr[i];
						itemNames = itemNames + "," + nameArr[i];
						maxValues = maxValues + "," + maxValueArr[i];
						minValues = minValues + "," + minValueArr[i];
						standardValues = standardValues + "," + standardValueArr[i];
					}
					if (idArr[i].split(":")[1] == "0") {
						if (valueArr[i] == "1") {
							strDel = "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelItem(\""
								+ itemIdStr + "\");'></td><td width='10%' algin='center style='display:none; '>"
								+ codeArr[i] + "</td><td width='25%' algin='center'>"
								+ nameArr[i] + "</td><td width='15%' algin='center'>"
								+ maxValueArr[i] + "</td><td width='15%' algin='center'>"
								+ minValueArr[i] + "</td><td width='15%' algin='center'>"
								+ standardValueArr[i] + "</td><td width='30%' algin='left'><select id='"
								+ itemIdStr + "'><option value='0'>未判定</option><option value='1' selected='true'>正常</option><option value='2'>异常</option></select></td></tr>"
						} else if (valueArr[i] == "2") {
							strDel = "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelItem(\""
								+ itemIdStr + "\");'></td><td width='10%' algin='center style='display:none; '>"
								+ codeArr[i] + "</td><td width='25%' algin='center'>"
								+ nameArr[i] + "</td><td width='15%' algin='center'>"
								+ maxValueArr[i] + "</td><td width='15%' algin='center'>"
								+ minValueArr[i] + "</td><td width='15%' algin='center'>"
								+ standardValueArr[i] + "</td><td width='30%' algin='left'><select id='"
								+ itemIdStr + "'><option value='0'>未判定</option><option value='1'>正常</option><option value='2' selected='true'>异常</option></select></td></tr>"
						} else {
							strDel = "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelItem(\""
								+ itemIdStr + "\");'></td><td width='10%' algin='center style='display:none; '>"
								+ codeArr[i] + "</td><td width='25%' algin='center'>"
								+ nameArr[i] + "</td><td width='15%' algin='center'>"
								+ maxValueArr[i] + "</td><td width='15%' algin='center'>"
								+ minValueArr[i] + "</td><td width='15%' algin='center'>"
								+ standardValueArr[i] + "</td><td width='30%' algin='left'><select id='"
								+ itemIdStr + "'><option value='0' selected='true'>未判定</option><option value='1'>正常</option><option value='2'>异常</option></select></td></tr>"
						}

					}
					if (idArr[i].split(":")[1] == "1") {
						strDel = "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelItem(\""
							+ itemIdStr + "\");'></td><td width='10%' algin='center style='display:none; '>"
							+ codeArr[i] + "</td><td width='25%' algin='center'>"
							+ nameArr[i] + "</td><td width='15%' algin='center'>"
							+ maxValueArr[i] + "</td><td width='15%' algin='center'>"
							+ minValueArr[i] + "</td><td width='15%' algin='center'>"
							+ standardValueArr[i] + "</td><td width='30%' algin='center'><input id='"
							+ itemIdStr + "' type='text' value='"
							+ valueArr[i] + "'></td></tr>"
					}

					$("#chkItemTableHead").append(strDel);
					//$api.html($api.byId("chkItemTableBody"), strDel);
				}
			}
			delItemIds = "";
		} else {
			alert("未选择要删除的点检项");
		}
	}

	function doDelHC() {
		if (delHCIds != "") {
			//过滤掉要删除的点检项
			setHCValues();
			var idArr = HCIds.split(",");
			var mrlGidArr = mrlGids.split(",");
			var mrlCodeArr = mrlCodes.split(",");
			var mrlNameArr = mrlNames.split(",");
			var consumeTypeArr = consumeTypes.split(",");
			var qtyArr = qtys.split(",");
			var remarkArr = remarks.split(",");

			HCIds = "";
			mrlGids = "";
			mrlCodes = "";
			mrlNames = "";
			consumeTypes = "";
			qtys = "";
			remarks = "";
			josnHCList = [];
			var HCIdStr = "";
			$("#chkHCTableBody").children().remove();
			//$("#chkHCTableBody").append("<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td style='display:none' algin='center'>物料编号</td><td width='30%' algin='center'>物料名称</td><td width='20%' algin='center'>数量</td><td width='20%' algin='center'>消耗类型</td><td width='20%' algin='center'>备注</td></tr>");
			var hmml = "<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td style='display:none' algin='center'>物料编号</td><td width='30%' algin='center'>物料名称</td><td width='20%' algin='center'>数量</td><td width='20%' algin='center'>消耗类型</td><td width='20%' algin='center'>备注</td></tr>";
			$api.html($api.byId("chkHCTableHead"), hmml);
			var seq = 0;
			for (i = 0; i < idArr.length; i++) {
				HCIdStr = idArr[i].split(":")[0];
				if (delHCIds.indexOf(HCIdStr) < 0) {
					seq++;
					//不在要删除的id字符串中
					var strDelHc = "";
					if (i == 0) {
						HCIds = idArr[i];
						mrlGids = mrlGidArr[i];
						mrlCodes = mrlCodeArr[i];
						mrlNames = mrlNameArr[i];
						consumeTypes = consumeTypeArr[i];
						qtys = qtyArr[i];
						remarks = remarkArr[i];
					} else {
						HCIds = HCIds + "," + idArr[i];
						mrlGids = mrlGids + "," + mrlGidArr[i];
						mrlCodes = mrlCodes + "," + mrlCodeArr[i];
						mrlNames = mrlNames + "," + mrlNameArr[i];
						consumeTypes = consumeTypes + "," + consumeTypeArr[i];
						qtys = qtys + "," + qtyArr[i];
						remarks = remarks + "," + remarkArr[i];
					}

					if (consumeTypeArr[i] === 0) {
						strDelHc += "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelHC(\"" + HCIdStr + "\");'></td><td style='display:none' algin='center'>" + mrlGidArr[i] + "</td><td style='display:none' algin='center'>" + mrlCodeArr[i] + "</td><td width='30%' algin='center'>" + mrlNameArr[i] + "</td><td width='20%' algin='center'><input id='qty_" + HCIdStr + "' type='text' value='" + qtyArr[i] + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCIdStr + "'><option value='0' selected='true'>替换</option><option value='1'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCIdStr + "' type='text' value='" + remarkArr[i] + "'></td></tr>"
					} else if (consumeTypeArr[i] === 1) {
						strDelHc += "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelHC(\"" + HCIdStr + "\");'></td><td style='display:none' algin='center'>" + mrlGidArr[i] + "</td><td style='display:none' algin='center'>" + mrlCodeArr[i] + "</td><td width='30%' algin='center'>" + mrlNameArr[i] + "</td><td width='20%' algin='center'><input id='qty_" + HCIdStr + "' type='text' value='" + qtyArr[i] + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCIdStr + "'><option value='0'>替换</option><option value='1' selected='true'>废弃</option><option value='2'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCIdStr + "' type='text' value='" + remarkArr[i] + "'></td></tr>"
					} else {
						strDelHc += "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelHC(\"" + HCIdStr + "\");'></td><td style='display:none' algin='center'>" + mrlGidArr[i] + "</td><td style='display:none' algin='center'>" + mrlCodeArr[i] + "</td><td width='30%' algin='center'>" + mrlNameArr[i] + "</td><td width='20%' algin='center'><input id='qty_" + HCIdStr + "' type='text' value='" + qtyArr[i] + "'></td><td width='20%' algin='left'><select id='consumeType_" + HCIdStr + "'><option value='0'>替换</option><option value='1'>废弃</option><option value='2' selected='true'>其他</option></select></td><td width='20%' algin='center'><input id='remark_" + HCIdStr + "' type='text' value='" + remarkArr[i] + "'></td></tr>"
					}

					$("#chkHCTableHead").append(strDelHc);
				}
			}
			delHCIds = "";
		} else {
			alert("未选择要删除的点检项");
		}
	}

	function doDelYq() {

		if (delYqIds != "") {
			//过滤掉要删除的点检项
			setYqValues();
			var idArr = YqIds.split(",");
			var mrlYqGidArr = mrlYqGids.split(",");
			var mrlYqCodeArr = mrlYqCodes.split(",");
			var mrlYqNameArr = mrlYqNames.split(",");
			var remarkYqArr = remarkYqs.split(",");
			YqIds = "";
			mrlYqGids = "";
			mrlYqCodes = "";
			mrlYqNames = "";
			remarkYqs = "";
			josnYqList = [];
			var YqIdStr = "";
			$("#chkYqTableHead").children().remove();
			$("#chkYqTableHead").append("<tr id='tr2'><td width='10%' algin='center'>序号</td><td style='display:none' algin='center'>物料主键</td><td width='30%' algin='center'>物料编码</td><td width='30%' algin='center'>物料名称</td><td width='30%' algin='center'>备注</td></tr>");
			var seq = 0;
			for (i = 0; i < idArr.length; i++) {
				YqIdStr = idArr[i].split(":")[0];

				if (delYqIds.indexOf(YqIdStr) < 0) {
					seq++;
					//不在要删除的id字符串中
					var str = "";
					if (i == 0) {
						YqIds = idArr[i];
						mrlYqGids = mrlYqGidArr[i];
						mrlYqCodes = mrlYqCodeArr[i];
						mrlYqNames = mrlYqNameArr[i];
						remarkYqs = remarkYqArr[i];
					} else {
						YqIds = YqIds + "," + idArr[i];
						//console.log(YqIds);	
						mrlYqGids = mrlYqGids + "," + mrlYqGidArr[i];
						mrlYqCodes = mrlYqCodes + "," + mrlYqCodeArr[i];
						mrlYqNames = mrlYqNames + "," + mrlYqNameArr[i];
						remarkYqs = remarkYqs + "," + remarkYqArr[i];
					}

					str = "<tr ><td width='10%' algin='center'><input type='checkbox' onclick='setDelYq(\"" + YqIdStr + "\");'></td><td style='display:none' algin='center'>" + mrlYqGidArr[i] + "</td><td width='30%' algin='center'>" + mrlYqCodeArr[i] + "</td><td width='30%' algin='center'>" + mrlYqNameArr[i] + "</td><td width='30%' algin='center'><input id='remarkYq_" + YqIdStr + "' type='text' value='" + remarkYqArr[i] + "'></td></tr>"
					$("#chkYqTableHead").append(str);
				}
			}
			delYqIds = "";
		} else {
			alert("未选择要删除的点检项");
		}
	}

	//删除检测维修仪器
	function setDelYq(id) {
		if (delYqIds == "") {
			delYqIds = id;
		} else {
			if (delYqIds.indexOf(id) > 0) {
				//已存在
				var delArr = delYqIds.split(",");
				delYqIds = "";
				for (i = 0; i < delArr.length; i++) {
					if (delArr[i] != id) {
						if (i == 0) {
							delYqIds = delArr[i];
						} else {
							delYqIds = delYqIds + "," + delArr[i];
						}
					}
				}
			} else {
				//不存在
				delYqIds = delYqIds + "," + id;
			}
		}
	}

	function doSave(type) {
		if (itemIds != "") {
			//点检项表格中有数据
			setItemValues();
			//保存耗材
			setHCValues();
			//保存耗材
			setYqValues();
			//提交数据到服务端
			doSubmit(type);
		} else {
			alert("无点检项信息，无法提交数据");
		}
	}

	function setItemValues() {
		var itemIdArr = itemIds.split(",");
		var itemValue = "";
		var un = localStorage.getItem('un');
		for (i = 0; i < itemIdArr.length; i++) {
			var itemStrArr = itemIdArr[i].split(":");
			var itemCodeArr = itemCodes.split(",");
			var itemNameArr = itemNames.split(",");
			var itemMaxValueArr = itemMaxValues.split(",");
			var itemMinValueArr = itemMinValues.split(",");
			var chkValue = "";
			var checkResult = "";
			var taskState = document.getElementById("zxState").value;
			var taskResult = document.getElementById("zxResult").value;
			var actualBeginDate = document.getElementById("actualBeginDate").value;
			var actualEndDate = document.getElementById("actualEndDate").value;
			if (itemStrArr[1] == "0") {
				//获取下拉框选中的值
				itemValue = document.getElementById(itemStrArr[0]).value;//选中的值
				checkResult = itemValue;
			}
			if (itemStrArr[1] == "1") {
				//获取文本框填的值
				itemValue = document.getElementById(itemStrArr[0]).value
				chkValue = itemValue;
				if (parseFloat(chkValue) >= parseFloat(itemMinValueArr[i]) && parseFloat(chkValue) <= parseFloat(itemMaxValueArr[i])) {
					//检验结果 0未判定/1正常/2异常
					checkResult = 1;
				} else {
					checkResult = 2;
				}
			}

			if (i == 0) {
				itemValues = itemValue;
			} else {
				itemValues = itemValues + "," + itemValue;
			}
			//将点检项的结果转化为jsonList
			var chkBeginTime = document.getElementById("actualBeginDate").value;
			var iObj = new itemObj(itemStrArr[0], itemCodeArr[i], itemNameArr[i], chkValue, checkResult, un, taskState, taskResult, chkBeginTime);
			josnList.push(iObj);
		}
	}

	function setHCValues() {
		var HCIdArr = HCIds.split(",");
		if (HCIdArr == '' || HCIdArr == undefined) {
			return;
		} else {
			var un = localStorage.getItem('un');
			for (i = 0; i < HCIdArr.length; i++) {
				var HCStrArr = HCIdArr[i].split(":");
				var mrlGidArr = mrlGids.split(",");
				var mrlCodeArr = mrlCodes.split(",");
				var mrlNameArr = mrlNames.split(",");

				var qtyValue = "";
				var consumeTypeValue = "";
				var remarkValue = "";

				qtyValue = document.getElementById("qty_" + HCStrArr[0]).value;
				consumeTypeValue = document.getElementById("consumeType_" + HCStrArr[0]).value;
				remarkValue = document.getElementById("remark_" + HCStrArr[0]).value;
				var operType = 0;
				var hObj = new HCObj(HCStrArr[0], mrlGidArr[i], mrlCodeArr[i], mrlNameArr[i], qtyValue, consumeTypeValue, remarkValue, un, operType);
				josnHCList.push(hObj);

			}
		}
	}

	function setYqValues() {
		var YqIdArr = YqIds.split(",");
		if (YqIdArr == '' || YqIdArr == undefined) {
			return;
		} else {
			var un = localStorage.getItem('un');
			for (i = 0; i < YqIdArr.length; i++) {
				var YqStrArr = YqIdArr[i].split(":");
				var mrlYqGidArr = mrlYqGids.split(",");
				var mrlYqCodeArr = mrlYqCodes.split(",");
				var mrlYqNameArr = mrlYqNames.split(",");
				var remarkYqValue = "";
				remarkYqValue = document.getElementById("remarkYq_" + YqStrArr[0]).value;
				var operType = 1;
				var hObj = new YqObj(YqStrArr[0], mrlYqGidArr[i], mrlYqCodeArr[i], mrlYqNameArr[i], remarkYqValue, un, operType);
				josnYqList.push(hObj);
			}
		}
	}


	function itemObj(chkItemId, chkItemCode, chkItemName, chkValue, checkResult, chkPerson, taskState, taskResult, chkBeginTime) {
		this.chkItemGid = chkItemId;
		this.chkItemCode = chkItemCode;
		this.chkItemName = chkItemName;
		this.chkValue = chkValue;
		this.checkResult = checkResult;
		this.taskState = taskState;
		this.taskResult = taskResult;
		this.chkBeginTime = chkBeginTime;
	}

	function HCObj(HCId, mrlGid, mrlCode, mrlName, qty, consumeType, remark, operPerson, operType) {
		this.HCId = HCId;
		this.mrlGid = mrlGid;
		this.mrlCode = mrlCode;
		this.mrlName = mrlName;
		this.qty = qty;
		this.consumeType = consumeType;
		this.remark = remark;
		this.operPerson = operPerson;
		this.operType = operType;
	}

	function YqObj(taskPartGid, mrlGid, mrlCode, mrlName, remark, operPerson, operType) {
		this.taskPartGid = taskPartGid;
		this.mrlGid = mrlGid;
		this.mrlCode = mrlCode;
		this.mrlName = mrlName;
		this.remark = remark;
		this.operPerson = operPerson;
		this.operType = operType;
	}

	function doSubmit() {
		var type = document.getElementById("zxResult").value;
		var taskState = document.getElementById("zxState").value;
		var actualBeginDate = document.getElementById("actualBeginDate").value;
		var actualEndDate = document.getElementById("actualEndDate").value;
		api.showProgress();
		var equipCode = document.getElementById("sm").value;
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/saveTaskItem2";
		var un = localStorage.getItem('un');
		// var pw = localStorage.getItem('pw');
		// var serverIp = localStorage.getItem('serverIp');
		// var serverPort = localStorage.getItem('serverPort');
		// var serverProject = localStorage.getItem('serverProject');
		// var url1 = serverIp+":"+serverPort+"/"+serverProject;

		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';
		params.returnAll = 'false';
		params.timeout = 60;

		api.showProgress({
			title: '保存中...',
		});

		var data = {
			values: {
				un: un,
				// pw: pw,
				// url: url1,
				taskId: taskId,
				rowData: JSON.stringify(josnList),
				rowHCData: JSON.stringify(josnHCList),
				rowYqData: JSON.stringify(josnYqList),
				type: type,
				taskState: taskState,
				equipCode: equipCode,
				actualBeginDate: actualBeginDate,
				actualEndDate: actualEndDate
			}
		};

		api.ajax({
			url: url,
			method: 'post',
			dataType: 'json',
			timeout: 300,
			returnAll: false,
			data: data
		}, function (ret, err) {
			if (ret) {
				var data = JSON.stringify(ret);
				var myobj = eval("(" + data + ")");
				//成功
				if (myobj.code == '0') {

					api.hideProgress();
					api.toast({
						msg: "保存成功",
						duration: 3000
					});
					api.closeWin();
		
                    api.execScript({
                        // name : 'about2',
                        // frameName : 'about-con',
                        name : 'createEquipTask',
                        script: 'doSubmit()'
                        //script : 'setEquipTask("'+id+'","'+code+'","'+equipId+'","'+SRequipCode+'","'+actualBeginDate+'","'+actualEndDate+'","'+taskResult+'")'
                    });

				} else if (myobj.code == '1') {
					api.hideProgress();
					api.toast({
						msg: myobj.message,
						duration: 3000
					});
				}
			} else {
				api.hideProgress();
				alert(JSON.stringify(err));
			}
		});
	}
	//返回按钮
	function closeWin() {
		api.closeWin({});
	}
</script>

</html>